package com.p595263720.o_amap.location.model;

import android.util.Log;

import com.amap.api.location.AMapLocationClientOption;

public class UnifiedLocationClientOptions {
    private boolean isMockEnabl;
    private int interval;
    private boolean isOnceLocation;
    private boolean isNeedAddress;
    private boolean isWifiScan;
    private int locationMode;
    private int locationProtocol;
    private boolean isKillProcess;
    private boolean isGpsFirst;
    private int httpTimeOut;
    private boolean isOffset;
    private boolean isLocationCacheEnable;
    private boolean isOnceLocationLatest;
    private boolean isSensorEnable;
    private int lastLocationLifeCycle;
    private int geoLanguage;
    private boolean isDownloadCoordinateConvertLibrary;
    private double deviceModeDistanceFilter;
    private int locationPurpose;
    private boolean isOpenAlwaysScanWifi;
    private int scanWifiInterval;

    public AMapLocationClientOption toLocationClientOptions() {
        AMapLocationClientOption.setDownloadCoordinateConvertLibrary(isDownloadCoordinateConvertLibrary);
        AMapLocationClientOption.setOpenAlwaysScanWifi(isOpenAlwaysScanWifi);
        AMapLocationClientOption.setScanWifiInterval(scanWifiInterval);
        if (locationProtocol == 1) {
            AMapLocationClientOption.setLocationProtocol(AMapLocationClientOption.AMapLocationProtocol.HTTPS);
        } else {
            AMapLocationClientOption.setLocationProtocol(AMapLocationClientOption.AMapLocationProtocol.HTTP);
        }
        AMapLocationClientOption.GeoLanguage geno = AMapLocationClientOption.GeoLanguage.DEFAULT;
        if (geoLanguage == 1) {
            geno = AMapLocationClientOption.GeoLanguage.ZH;
        } else if (geoLanguage == 2) {
            geno = AMapLocationClientOption.GeoLanguage.EN;
        } else {
            geno = AMapLocationClientOption.GeoLanguage.DEFAULT;
        }
        AMapLocationClientOption.AMapLocationMode mode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy;
        if (locationMode == 0) {
            mode = AMapLocationClientOption.AMapLocationMode.Battery_Saving;
        } else if (locationMode == 1) {
            mode = AMapLocationClientOption.AMapLocationMode.Device_Sensors;
        } else {
            mode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy;
        }
        AMapLocationClientOption.AMapLocationPurpose purpose = null;
        if (locationPurpose == 0) {
            purpose = AMapLocationClientOption.AMapLocationPurpose.SignIn;
        } else if (locationPurpose == 1) {
            purpose = AMapLocationClientOption.AMapLocationPurpose.Transport;
        } else if (locationPurpose == 2) {
            purpose = AMapLocationClientOption.AMapLocationPurpose.Sport;
        }
        AMapLocationClientOption option = new AMapLocationClientOption();
        option.setMockEnable(isMockEnabl)
                .setInterval(interval)
                .setOnceLocation(isOnceLocation)
                .setNeedAddress(isNeedAddress)
                .setWifiScan(isWifiScan)
                .setKillProcess(isKillProcess)
                .setGpsFirst(isGpsFirst)
                .setHttpTimeOut(httpTimeOut)
                .setOffset(isOffset)
                .setLocationCacheEnable(isLocationCacheEnable)
                .setOnceLocationLatest(isOnceLocationLatest)
                .setSensorEnable(isSensorEnable)
                .setLastLocationLifeCycle(lastLocationLifeCycle)
                .setGeoLanguage(geno)
                .setLocationMode(mode)
                .setDeviceModeDistanceFilter((float)deviceModeDistanceFilter)
                .setLocationPurpose(purpose);
        return option;
    }
}
